package org.jeecg.modules.online.p002a;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.DbType;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.system.query.MatchTypeEnum;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.query.QueryRuleEnum;
import org.jeecg.common.system.util.JeecgDataAutorUtils;
import org.jeecg.common.system.vo.SysPermissionDataRuleModel;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.online.auth.p004b.AuthConstants;
import org.jeecg.modules.online.cgform.consts.ExtendJsonKey;
import org.jeecg.modules.online.cgform.entity.OnlCgformField;
import org.jeecg.modules.online.cgform.service.IOnlCgformFieldService;
import org.jeecg.modules.online.cgform.utils.CgformUtil;
import org.jeecg.modules.online.cgreport.constant.CgReportConstant;
import org.jeecg.modules.online.config.p020b.DataBaseConfig;
import org.jeecg.modules.online.config.p020b.OnlineFieldConfig;
import org.jeecg.modules.online.config.p022d.DataBaseConst;
import org.jeecg.modules.online.config.p022d.DbTableUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/* renamed from: org.jeecg.modules.online.a.a */
/* loaded from: hibernate-re-3.7.1-RC.jar:org/jeecg/modules/online/a/a.class */
public class ConditionHandler {

    /* renamed from: d */
    private static final Logger f66d = LoggerFactory.getLogger(ConditionHandler.class);

    /* renamed from: a */
    public static final String f67a = "jdbcTemplate";

    /* renamed from: b */
    public static final String f68b = "mybatis";

    /* renamed from: e */
    private String f69e;

    /* renamed from: f */
    private String f70f;

    /* renamed from: g */
    private String f71g;

    /* renamed from: h */
    private boolean f72h;

    /* renamed from: i */
    private List<OnlineFieldConfig> f73i;

    /* renamed from: j */
    private List<String> f74j;

    /* renamed from: k */
    private List<SysPermissionDataRuleModel> f75k;

    /* renamed from: l */
    private Map<String, Object> f76l;

    /* renamed from: m */
    private StringBuffer f77m;

    /* renamed from: n */
    private StringBuffer f78n;

    /* renamed from: o */
    private Map<String, Object> f79o;

    /* renamed from: p */
    private String f80p;

    /* renamed from: q */
    private boolean f81q;

    /* renamed from: r */
    private String f82r;

    /* renamed from: s */
    private int f83s;

    /* renamed from: t */
    private boolean f84t;

    /* renamed from: u */
    private String f85u;

    /* renamed from: v */
    private Map<String, String> f86v;

    /* renamed from: w */
    private Map<String, String> f87w;

    /* renamed from: x */
    private String f88x;

    /* renamed from: c */
    public String f89c;

    public void setAlias(String alias) {
        this.f69e = alias;
    }

    public void setAliasNoPoint(String aliasNoPoint) {
        this.f70f = aliasNoPoint;
    }

    public void setDataBaseType(String dataBaseType) {
        this.f71g = dataBaseType;
    }

    public void setDateStringSearch(boolean dateStringSearch) {
        this.f72h = dateStringSearch;
    }

    public void setFieldList(List<OnlineFieldConfig> fieldList) {
        this.f73i = fieldList;
    }

    public void setNeedList(List<String> needList) {
        this.f74j = needList;
    }

    public void setAuthDatalist(List<SysPermissionDataRuleModel> authDatalist) {
        this.f75k = authDatalist;
    }

    public void setReqParams(Map<String, Object> reqParams) {
        this.f76l = reqParams;
    }

    public void setSql(StringBuffer sql) {
        this.f77m = sql;
    }

    public void setSuperQuerySql(StringBuffer superQuerySql) {
        this.f78n = superQuerySql;
    }

    public void setSqlParams(Map<String, Object> sqlParams) {
        this.f79o = sqlParams;
    }

    public void setDaoType(String daoType) {
        this.f80p = daoType;
    }

    public void setSuperQuery(boolean superQuery) {
        this.f81q = superQuery;
    }

    public void setMatchType(String matchType) {
        this.f82r = matchType;
    }

    public void setUsePage(int usePage) {
        this.f83s = usePage;
    }

    public void setFirst(boolean first) {
        this.f84t = first;
    }

    public void setParamPrefix(String paramPrefix) {
        this.f85u = paramPrefix;
    }

    public void setDuplicateSqlNameRecord(Map<String, String> duplicateSqlNameRecord) {
        this.f86v = duplicateSqlNameRecord;
    }

    public void setDuplicateParamNameRecord(Map<String, String> duplicateParamNameRecord) {
        this.f87w = duplicateParamNameRecord;
    }

    public void setTableName(String tableName) {
        this.f88x = tableName;
    }

    public void setSubTableStr(String subTableStr) {
        this.f89c = subTableStr;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (o instanceof ConditionHandler) {
            ConditionHandler conditionHandler = (ConditionHandler) o;
            if (conditionHandler.m580a(this) && m581a() == conditionHandler.m581a() && m560b() == conditionHandler.m560b() && getUsePage() == conditionHandler.getUsePage() && m551c() == conditionHandler.m551c()) {
                String alias = getAlias();
                String alias2 = conditionHandler.getAlias();
                if (alias == null) {
                    if (alias2 != null) {
                        return false;
                    }
                } else if (!alias.equals(alias2)) {
                    return false;
                }
                String aliasNoPoint = getAliasNoPoint();
                String aliasNoPoint2 = conditionHandler.getAliasNoPoint();
                if (aliasNoPoint == null) {
                    if (aliasNoPoint2 != null) {
                        return false;
                    }
                } else if (!aliasNoPoint.equals(aliasNoPoint2)) {
                    return false;
                }
                String dataBaseType = getDataBaseType();
                String dataBaseType2 = conditionHandler.getDataBaseType();
                if (dataBaseType == null) {
                    if (dataBaseType2 != null) {
                        return false;
                    }
                } else if (!dataBaseType.equals(dataBaseType2)) {
                    return false;
                }
                List<OnlineFieldConfig> fieldList = getFieldList();
                List<OnlineFieldConfig> fieldList2 = conditionHandler.getFieldList();
                if (fieldList == null) {
                    if (fieldList2 != null) {
                        return false;
                    }
                } else if (!fieldList.equals(fieldList2)) {
                    return false;
                }
                List<String> needList = getNeedList();
                List<String> needList2 = conditionHandler.getNeedList();
                if (needList == null) {
                    if (needList2 != null) {
                        return false;
                    }
                } else if (!needList.equals(needList2)) {
                    return false;
                }
                List<SysPermissionDataRuleModel> authDatalist = getAuthDatalist();
                List<SysPermissionDataRuleModel> authDatalist2 = conditionHandler.getAuthDatalist();
                if (authDatalist == null) {
                    if (authDatalist2 != null) {
                        return false;
                    }
                } else if (!authDatalist.equals(authDatalist2)) {
                    return false;
                }
                Map<String, Object> reqParams = getReqParams();
                Map<String, Object> reqParams2 = conditionHandler.getReqParams();
                if (reqParams == null) {
                    if (reqParams2 != null) {
                        return false;
                    }
                } else if (!reqParams.equals(reqParams2)) {
                    return false;
                }
                StringBuffer sql = getSql();
                StringBuffer sql2 = conditionHandler.getSql();
                if (sql == null) {
                    if (sql2 != null) {
                        return false;
                    }
                } else if (!sql.equals(sql2)) {
                    return false;
                }
                StringBuffer superQuerySql = getSuperQuerySql();
                StringBuffer superQuerySql2 = conditionHandler.getSuperQuerySql();
                if (superQuerySql == null) {
                    if (superQuerySql2 != null) {
                        return false;
                    }
                } else if (!superQuerySql.equals(superQuerySql2)) {
                    return false;
                }
                Map<String, Object> sqlParams = getSqlParams();
                Map<String, Object> sqlParams2 = conditionHandler.getSqlParams();
                if (sqlParams == null) {
                    if (sqlParams2 != null) {
                        return false;
                    }
                } else if (!sqlParams.equals(sqlParams2)) {
                    return false;
                }
                String daoType = getDaoType();
                String daoType2 = conditionHandler.getDaoType();
                if (daoType == null) {
                    if (daoType2 != null) {
                        return false;
                    }
                } else if (!daoType.equals(daoType2)) {
                    return false;
                }
                String matchType = getMatchType();
                String matchType2 = conditionHandler.getMatchType();
                if (matchType == null) {
                    if (matchType2 != null) {
                        return false;
                    }
                } else if (!matchType.equals(matchType2)) {
                    return false;
                }
                String paramPrefix = getParamPrefix();
                String paramPrefix2 = conditionHandler.getParamPrefix();
                if (paramPrefix == null) {
                    if (paramPrefix2 != null) {
                        return false;
                    }
                } else if (!paramPrefix.equals(paramPrefix2)) {
                    return false;
                }
                Map<String, String> duplicateSqlNameRecord = getDuplicateSqlNameRecord();
                Map<String, String> duplicateSqlNameRecord2 = conditionHandler.getDuplicateSqlNameRecord();
                if (duplicateSqlNameRecord == null) {
                    if (duplicateSqlNameRecord2 != null) {
                        return false;
                    }
                } else if (!duplicateSqlNameRecord.equals(duplicateSqlNameRecord2)) {
                    return false;
                }
                Map<String, String> duplicateParamNameRecord = getDuplicateParamNameRecord();
                Map<String, String> duplicateParamNameRecord2 = conditionHandler.getDuplicateParamNameRecord();
                if (duplicateParamNameRecord == null) {
                    if (duplicateParamNameRecord2 != null) {
                        return false;
                    }
                } else if (!duplicateParamNameRecord.equals(duplicateParamNameRecord2)) {
                    return false;
                }
                String tableName = getTableName();
                String tableName2 = conditionHandler.getTableName();
                if (tableName == null) {
                    if (tableName2 != null) {
                        return false;
                    }
                } else if (!tableName.equals(tableName2)) {
                    return false;
                }
                String subTableStr = getSubTableStr();
                String subTableStr2 = conditionHandler.getSubTableStr();
                return subTableStr == null ? subTableStr2 == null : subTableStr.equals(subTableStr2);
            }
            return false;
        }
        return false;
    }

    /* renamed from: a */
    protected boolean m580a(Object obj) {
        return obj instanceof ConditionHandler;
    }

    public int hashCode() {
        int usePage = (((((((1 * 59) + (m581a() ? 79 : 97)) * 59) + (m560b() ? 79 : 97)) * 59) + getUsePage()) * 59) + (m551c() ? 79 : 97);
        String alias = getAlias();
        int hashCode = (usePage * 59) + (alias == null ? 43 : alias.hashCode());
        String aliasNoPoint = getAliasNoPoint();
        int hashCode2 = (hashCode * 59) + (aliasNoPoint == null ? 43 : aliasNoPoint.hashCode());
        String dataBaseType = getDataBaseType();
        int hashCode3 = (hashCode2 * 59) + (dataBaseType == null ? 43 : dataBaseType.hashCode());
        List<OnlineFieldConfig> fieldList = getFieldList();
        int hashCode4 = (hashCode3 * 59) + (fieldList == null ? 43 : fieldList.hashCode());
        List<String> needList = getNeedList();
        int hashCode5 = (hashCode4 * 59) + (needList == null ? 43 : needList.hashCode());
        List<SysPermissionDataRuleModel> authDatalist = getAuthDatalist();
        int hashCode6 = (hashCode5 * 59) + (authDatalist == null ? 43 : authDatalist.hashCode());
        Map<String, Object> reqParams = getReqParams();
        int hashCode7 = (hashCode6 * 59) + (reqParams == null ? 43 : reqParams.hashCode());
        StringBuffer sql = getSql();
        int hashCode8 = (hashCode7 * 59) + (sql == null ? 43 : sql.hashCode());
        StringBuffer superQuerySql = getSuperQuerySql();
        int hashCode9 = (hashCode8 * 59) + (superQuerySql == null ? 43 : superQuerySql.hashCode());
        Map<String, Object> sqlParams = getSqlParams();
        int hashCode10 = (hashCode9 * 59) + (sqlParams == null ? 43 : sqlParams.hashCode());
        String daoType = getDaoType();
        int hashCode11 = (hashCode10 * 59) + (daoType == null ? 43 : daoType.hashCode());
        String matchType = getMatchType();
        int hashCode12 = (hashCode11 * 59) + (matchType == null ? 43 : matchType.hashCode());
        String paramPrefix = getParamPrefix();
        int hashCode13 = (hashCode12 * 59) + (paramPrefix == null ? 43 : paramPrefix.hashCode());
        Map<String, String> duplicateSqlNameRecord = getDuplicateSqlNameRecord();
        int hashCode14 = (hashCode13 * 59) + (duplicateSqlNameRecord == null ? 43 : duplicateSqlNameRecord.hashCode());
        Map<String, String> duplicateParamNameRecord = getDuplicateParamNameRecord();
        int hashCode15 = (hashCode14 * 59) + (duplicateParamNameRecord == null ? 43 : duplicateParamNameRecord.hashCode());
        String tableName = getTableName();
        int hashCode16 = (hashCode15 * 59) + (tableName == null ? 43 : tableName.hashCode());
        String subTableStr = getSubTableStr();
        return (hashCode16 * 59) + (subTableStr == null ? 43 : subTableStr.hashCode());
    }

    public String toString() {
        return "ConditionHandler(alias=" + getAlias() + ", aliasNoPoint=" + getAliasNoPoint() + ", dataBaseType=" + getDataBaseType() + ", dateStringSearch=" + m581a() + ", fieldList=" + getFieldList() + ", needList=" + getNeedList() + ", authDatalist=" + getAuthDatalist() + ", reqParams=" + getReqParams() + ", sql=" + ((Object) getSql()) + ", superQuerySql=" + ((Object) getSuperQuerySql()) + ", sqlParams=" + getSqlParams() + ", daoType=" + getDaoType() + ", superQuery=" + m560b() + ", matchType=" + getMatchType() + ", usePage=" + getUsePage() + ", first=" + m551c() + ", paramPrefix=" + getParamPrefix() + ", duplicateSqlNameRecord=" + getDuplicateSqlNameRecord() + ", duplicateParamNameRecord=" + getDuplicateParamNameRecord() + ", tableName=" + getTableName() + ", subTableStr=" + getSubTableStr() + ")";
    }

    public String getAlias() {
        return this.f69e;
    }

    public String getAliasNoPoint() {
        return this.f70f;
    }

    public String getDataBaseType() {
        return this.f71g;
    }

    /* renamed from: a */
    public boolean m581a() {
        return this.f72h;
    }

    public List<OnlineFieldConfig> getFieldList() {
        return this.f73i;
    }

    public List<String> getNeedList() {
        return this.f74j;
    }

    public List<SysPermissionDataRuleModel> getAuthDatalist() {
        return this.f75k;
    }

    public Map<String, Object> getReqParams() {
        return this.f76l;
    }

    public StringBuffer getSql() {
        return this.f77m;
    }

    public StringBuffer getSuperQuerySql() {
        return this.f78n;
    }

    public Map<String, Object> getSqlParams() {
        return this.f79o;
    }

    public String getDaoType() {
        return this.f80p;
    }

    /* renamed from: b */
    public boolean m560b() {
        return this.f81q;
    }

    public String getMatchType() {
        return this.f82r;
    }

    public int getUsePage() {
        return this.f83s;
    }

    /* renamed from: c */
    public boolean m551c() {
        return this.f84t;
    }

    public String getParamPrefix() {
        return this.f85u;
    }

    public Map<String, String> getDuplicateSqlNameRecord() {
        return this.f86v;
    }

    public Map<String, String> getDuplicateParamNameRecord() {
        return this.f87w;
    }

    public String getTableName() {
        return this.f88x;
    }

    public ConditionHandler() {
    }

    public ConditionHandler(String str, String str2) {
        DbType m27c;
        this.f69e = str;
        this.f70f = str.replace(".", "");
        this.f71g = str2;
        if (this.f71g == null && (m27c = DbTableUtil.m27c((DataBaseConfig) null)) != null) {
            this.f71g = m27c.getDb();
        }
        this.f72h = m539f(str2);
        this.f77m = new StringBuffer();
        this.f79o = new HashMap(5);
        this.f75k = null;
        this.f74j = null;
        this.f82r = CgformUtil.f207e;
        this.f83s = 1;
        this.f84t = true;
        this.f85u = "";
        this.f86v = new HashMap(5);
        this.f87w = new HashMap(5);
    }

    public ConditionHandler(String str) {
        this(str, null);
        this.f83s = 2;
    }

    public ConditionHandler(String str, boolean z, String str2) {
        this(str, null);
        this.f81q = z;
        this.f82r = " " + str2 + " ";
        this.f83s = 2;
    }

    /* renamed from: a */
    public String m564a(List<OnlineFieldConfig> list, Map<String, Object> map) {
        m547c(list, map);
        m546d();
        return this.f77m.toString();
    }

    /* renamed from: a */
    public String m563a(List<OnlineFieldConfig> list, Map<String, Object> map, List<SysPermissionDataRuleModel> list2) {
        setAuthDatalist(list2);
        m547c(list, map);
        m553b(list);
        m561a(map);
        m542e();
        return this.f77m.toString();
    }

    /* renamed from: a */
    public String m562a(List<OnlineFieldConfig> list, Map<String, Object> map, List<SysPermissionDataRuleModel> list2, String str) {
        setAuthDatalist(list2);
        this.f85u = str;
        m547c(list, map);
        m553b(list);
        m542e();
        return this.f77m.toString();
    }

    /* renamed from: b */
    public String m552b(List<OnlineFieldConfig> list, Map<String, Object> map) {
        m547c(list, map);
        return this.f77m.toString();
    }

    /* renamed from: a */
    public String m565a(List<OnlineFieldConfig> list) {
        if (this.f81q) {
            for (OnlineFieldConfig onlineFieldConfig : list) {
                String name = onlineFieldConfig.getName();
                String val = onlineFieldConfig.getVal();
                if (val != null) {
                    QueryRuleEnum byValue = QueryRuleEnum.getByValue(onlineFieldConfig.getRule());
                    if (byValue == null) {
                        byValue = QueryRuleEnum.EQ;
                    }
                    m572a(name, onlineFieldConfig.getType(), val, byValue);
                }
            }
        }
        return this.f77m.toString();
    }

    /* renamed from: c */
    public void m547c(List<OnlineFieldConfig> list, Map<String, Object> map) {
        Object obj;
        for (OnlineFieldConfig onlineFieldConfig : list) {
            String name = onlineFieldConfig.getName();
            String type = onlineFieldConfig.getType();
            if (this.f74j != null && this.f74j.contains(name)) {
                onlineFieldConfig.setIsSearch(1);
                onlineFieldConfig.setMode("single");
            }
            if (oConvertUtils.isNotEmpty(onlineFieldConfig.getMainField()) && oConvertUtils.isNotEmpty(onlineFieldConfig.getMainTable())) {
                onlineFieldConfig.setIsSearch(1);
                onlineFieldConfig.setMode("single");
            }
            if (1 == onlineFieldConfig.getIsSearch().intValue()) {
                if ("time".equals(onlineFieldConfig.getView()) && !CgReportConstant.f505K.equals(onlineFieldConfig.getMode())) {
                    onlineFieldConfig.setMode("single");
                }
                if (CgReportConstant.f505K.equals(onlineFieldConfig.getMode())) {
                    String str = name + "_begin";
                    Object obj2 = map.get(this.f85u + str);
                    if (null != obj2) {
                        m555b(name, CgReportConstant.f490v, type);
                        m556b(str, type, obj2);
                    }
                    String str2 = name + "_end";
                    Object obj3 = map.get(this.f85u + str2);
                    if (null != obj3) {
                        m555b(name, CgReportConstant.f491w, type);
                        m573a(str2, type, obj3, "end");
                    }
                } else {
                    Object obj4 = map.get(this.f85u + name);
                    if (obj4 != null) {
                        String view = onlineFieldConfig.getView();
                        if ("list_multi".equals(view) || "checkbox".equals(view) || "sel_depart".equalsIgnoreCase(view) || "sel_user".equalsIgnoreCase(view)) {
                            m540e(name, obj4);
                        } else if (CgformUtil.f241M.equals(view) || CgformUtil.f242N.equals(view)) {
                            m538f(name, obj4);
                        } else {
                            if ("umeditor".equalsIgnoreCase(view)) {
                                String obj5 = obj4.toString().startsWith("*") ? obj4.toString() : "*" + obj4.toString();
                                obj4 = obj5.toString().endsWith("*") ? obj5.toString() : obj5.toString() + "*";
                            }
                            m574a(name, type, (Object) obj4);
                        }
                    }
                }
            }
        }
        for (String str3 : map.keySet()) {
            if (str3.startsWith(CgReportConstant.f498D) && (obj = map.get(str3)) != null) {
                m574a(str3.replace(CgReportConstant.f498D, ""), "", obj);
            }
        }
    }

    public void setAuthList(List<SysPermissionDataRuleModel> authDatalist) {
        this.f75k = authDatalist;
    }

    /* renamed from: d */
    private void m546d() {
        SysPermissionDataRuleModel sysPermissionDataRuleModel;
        List loadDataSearchConditon = JeecgDataAutorUtils.loadDataSearchConditon();
        if (loadDataSearchConditon != null && loadDataSearchConditon.size() > 0) {
            for (int i = 0; i < loadDataSearchConditon.size() && (sysPermissionDataRuleModel = (SysPermissionDataRuleModel) loadDataSearchConditon.get(i)) != null; i++) {
                String ruleValue = sysPermissionDataRuleModel.getRuleValue();
                if (!oConvertUtils.isEmpty(ruleValue)) {
                    if (QueryRuleEnum.SQL_RULES.getValue().equals(sysPermissionDataRuleModel.getRuleConditions())) {
                        m557b("", QueryGenerator.getSqlRuleValue(ruleValue));
                    } else {
                        QueryRuleEnum byValue = QueryRuleEnum.getByValue(sysPermissionDataRuleModel.getRuleConditions());
                        String str = "Integer";
                        String trim = ruleValue.trim();
                        if (trim.startsWith(CgformUtil.f231C) && trim.endsWith(CgformUtil.f231C)) {
                            str = "string";
                            trim = trim.substring(1, trim.length() - 1);
                        } else if (trim.startsWith("#{") && trim.endsWith("}")) {
                            str = "string";
                        }
                        m572a(sysPermissionDataRuleModel.getRuleColumn(), str, m579a(trim), byValue);
                    }
                }
            }
        }
    }

    /* renamed from: a */
    private String m579a(String str) {
        Pattern compile = Pattern.compile("#\\{.*?}");
        Matcher matcher = compile.matcher(str);
        while (matcher.find()) {
            String group = matcher.group();
            if (oConvertUtils.isNotEmpty(group)) {
                String converRuleValue = QueryGenerator.converRuleValue(group);
                str = matcher.replaceFirst(Matcher.quoteReplacement(converRuleValue != null ? converRuleValue : ""));
                matcher = compile.matcher(str);
            }
        }
        return str;
    }

    /* renamed from: a */
    private OnlineFieldConfig m567a(String str, List<OnlineFieldConfig> list) {
        if (list != null && str != null) {
            String camelToUnderline = oConvertUtils.camelToUnderline(str);
            for (int i = 0; i < list.size(); i++) {
                OnlineFieldConfig onlineFieldConfig = list.get(i);
                String name = onlineFieldConfig.getName();
                if (str.equals(name) || camelToUnderline.equals(name)) {
                    return onlineFieldConfig;
                }
            }
            return null;
        }
        return null;
    }

    /* renamed from: b */
    private void m553b(List<OnlineFieldConfig> list) {
        SysPermissionDataRuleModel sysPermissionDataRuleModel;
        List<SysPermissionDataRuleModel> list2 = this.f75k;
        if (list2 == null) {
            list2 = JeecgDataAutorUtils.loadDataSearchConditon();
        }
        if (list2 != null && list2.size() > 0) {
            for (int i = 0; i < list2.size() && (sysPermissionDataRuleModel = list2.get(i)) != null; i++) {
                String ruleValue = sysPermissionDataRuleModel.getRuleValue();
                if (!oConvertUtils.isEmpty(ruleValue)) {
                    if (QueryRuleEnum.SQL_RULES.getValue().equals(sysPermissionDataRuleModel.getRuleConditions())) {
                        m557b("", QueryGenerator.getSqlRuleValue(ruleValue));
                    } else {
                        String ruleColumn = sysPermissionDataRuleModel.getRuleColumn();
                        OnlineFieldConfig m567a = m567a(ruleColumn, list);
                        if (m567a != null) {
                            String converRuleValue = QueryGenerator.converRuleValue(ruleValue);
                            QueryRuleEnum byValue = QueryRuleEnum.getByValue(sysPermissionDataRuleModel.getRuleConditions());
                            String view = m567a.getView();
                            if (QueryRuleEnum.IN.equals(byValue)) {
                                if ("list_multi".equalsIgnoreCase(view) || "checkbox".equalsIgnoreCase(view) || "sel_depart".equalsIgnoreCase(view) || "sel_user".equalsIgnoreCase(view)) {
                                    m540e(ruleColumn, converRuleValue);
                                } else if (CgformUtil.f241M.equalsIgnoreCase(view) || CgformUtil.f242N.equalsIgnoreCase(view)) {
                                    m538f(ruleColumn, converRuleValue);
                                } else {
                                    m572a(m567a.getName(), m567a.getType(), converRuleValue, byValue);
                                }
                            } else {
                                m572a(m567a.getName(), m567a.getType(), converRuleValue, byValue);
                            }
                        }
                    }
                }
            }
        }
    }

    /* renamed from: e */
    private void m542e() {
        if (CgformUtil.m310j(CgformUtil.m317f(this.f88x))) {
            m572a("tenant_id", "int", SpringContextUtils.getHttpServletRequest().getHeader("X-Tenant-Id"), QueryRuleEnum.EQ);
        }
    }

    /* renamed from: a */
    private void m574a(String str, String str2, Object obj) {
        m572a(str, str2, obj, (QueryRuleEnum) null);
    }

    /* renamed from: a */
    private void m572a(String str, String str2, Object obj, QueryRuleEnum queryRuleEnum) {
        if (obj != null) {
            String obj2 = obj.toString();
            boolean z = false;
            if (queryRuleEnum == null) {
                z = true;
                queryRuleEnum = QueryGenerator.convert2Rule(obj);
            }
            if (z) {
                obj2 = obj2.trim();
            }
            switch (C00001.f90a[queryRuleEnum.ordinal()]) {
                case 1:
                case 2:
                    m555b(str, queryRuleEnum.getValue(), str2);
                    if (z) {
                        obj2 = obj2.substring(1);
                    }
                    m556b(str, str2, (Object) obj2);
                    return;
                case 3:
                case AuthConstants.f111o /* 4 */:
                    m555b(str, queryRuleEnum.getValue(), str2);
                    if (z) {
                        obj2 = obj2.substring(2);
                    }
                    m556b(str, str2, (Object) obj2);
                    return;
                case 5:
                    m555b(str, queryRuleEnum.getValue(), str2);
                    m556b(str, str2, (Object) obj2);
                    return;
                case 6:
                    m555b(str, queryRuleEnum.getValue(), str2);
                    if (z) {
                        obj2 = obj2.replaceAll("\\+\\+", CgformUtil.f233E);
                    }
                    m556b(str, str2, (Object) obj2);
                    return;
                case 7:
                    m570a(str, " <> ", this.f82r, "(");
                    if (z) {
                        obj2 = obj2.substring(1);
                    }
                    m556b(str, str2, (Object) obj2);
                    m569a(str, " IS NULL ) ", MatchTypeEnum.OR.getValue(), str2, null);
                    return;
                case 8:
                    m555b(str, " in ", str2);
                    m571a(str, str2, obj2);
                    return;
                case 9:
                case 10:
                case 11:
                    m555b(str, CgformUtil.f208f, str2);
                    if (z) {
                        m575a(str, obj2);
                        return;
                    } else {
                        m568a(str, obj2, queryRuleEnum);
                        return;
                    }
                case 12:
                case 13:
                    m554b(str, str2, queryRuleEnum);
                    return;
                default:
                    m555b(str, CgReportConstant.f489u, str2);
                    m556b(str, str2, (Object) obj2);
                    return;
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* compiled from: ConditionHandler.java */
    /* renamed from: org.jeecg.modules.online.a.a$1 */
    /* loaded from: hibernate-re-3.7.1-RC.jar:org/jeecg/modules/online/a/a$1.class */
    public static /* synthetic */ class C00001 {

        /* renamed from: a */
        static final /* synthetic */ int[] f90a = new int[QueryRuleEnum.values().length];

        static {
            try {
                f90a[QueryRuleEnum.GT.ordinal()] = 1;
            } catch (NoSuchFieldError e) {
            }
            try {
                f90a[QueryRuleEnum.LT.ordinal()] = 2;
            } catch (NoSuchFieldError e2) {
            }
            try {
                f90a[QueryRuleEnum.GE.ordinal()] = 3;
            } catch (NoSuchFieldError e3) {
            }
            try {
                f90a[QueryRuleEnum.LE.ordinal()] = 4;
            } catch (NoSuchFieldError e4) {
            }
            try {
                f90a[QueryRuleEnum.EQ.ordinal()] = 5;
            } catch (NoSuchFieldError e5) {
            }
            try {
                f90a[QueryRuleEnum.EQ_WITH_ADD.ordinal()] = 6;
            } catch (NoSuchFieldError e6) {
            }
            try {
                f90a[QueryRuleEnum.NE.ordinal()] = 7;
            } catch (NoSuchFieldError e7) {
            }
            try {
                f90a[QueryRuleEnum.IN.ordinal()] = 8;
            } catch (NoSuchFieldError e8) {
            }
            try {
                f90a[QueryRuleEnum.LIKE.ordinal()] = 9;
            } catch (NoSuchFieldError e9) {
            }
            try {
                f90a[QueryRuleEnum.RIGHT_LIKE.ordinal()] = 10;
            } catch (NoSuchFieldError e10) {
            }
            try {
                f90a[QueryRuleEnum.LEFT_LIKE.ordinal()] = 11;
            } catch (NoSuchFieldError e11) {
            }
            try {
                f90a[QueryRuleEnum.EMPTY.ordinal()] = 12;
            } catch (NoSuchFieldError e12) {
            }
            try {
                f90a[QueryRuleEnum.NOT_EMPTY.ordinal()] = 13;
            } catch (NoSuchFieldError e13) {
            }
        }
    }

    /* renamed from: a */
    private void m571a(String str, String str2, String str3) {
        String[] split = str3.split(CgformUtil.f233E);
        if (split.length == 0) {
            m559b("('')");
            return;
        }
        String str4 = "";
        for (int i = 0; i < split.length; i++) {
            String trim = split[i].trim();
            String format = String.format("foreach_%s_%s", str, Integer.valueOf(i));
            if (i > 0) {
                str4 = str4 + CgformUtil.f233E;
            }
            String m537g = m537g(format);
            if (f67a.equals(this.f80p)) {
                str4 = str4 + ":" + m537g;
            } else {
                str4 = str4 + "#{" + m550c(m537g) + "}";
            }
            if ("Long".equals(str2) || "Integer".equals(str2)) {
                m576a(format, Integer.valueOf(Integer.parseInt(trim)));
            } else {
                m576a(format, (Object) trim);
            }
        }
        m559b("(" + str4 + ")");
    }

    /* renamed from: a */
    private void m575a(String str, String str2) {
        String str3;
        m559b(m543d(str, "VARCHAR"));
        if ((str2.startsWith("*") && str2.endsWith("*")) || (str2.startsWith("%") && str2.endsWith("%"))) {
            str3 = "%" + str2.substring(1, str2.length() - 1) + "%";
        } else if (str2.startsWith("*") || str2.startsWith("%")) {
            str3 = "%" + str2.substring(1);
        } else if (str2.endsWith("*") || str2.endsWith("%")) {
            str3 = str2.substring(0, str2.length() - 1) + "%";
        } else {
            str3 = "%" + str2 + "%";
        }
        m576a(str, (Object) str3);
    }

    /* renamed from: a */
    private void m568a(String str, String str2, QueryRuleEnum queryRuleEnum) {
        m559b(m543d(str, "VARCHAR"));
        if (queryRuleEnum == QueryRuleEnum.LEFT_LIKE) {
            m576a(str, (Object) ("%" + str2));
        } else if (queryRuleEnum == QueryRuleEnum.RIGHT_LIKE) {
            m576a(str, (Object) (str2 + "%"));
        } else {
            m576a(str, (Object) ("%" + str2 + "%"));
        }
    }

    /* renamed from: b */
    private void m554b(String str, String str2, QueryRuleEnum queryRuleEnum) {
        if (this.f84t) {
            this.f84t = false;
        } else {
            this.f77m.append(" ").append(this.f82r).append(" ");
        }
        String m548c = m548c(str, str2);
        StringBuilder sb = new StringBuilder();
        boolean z = ExtendJsonKey.f133f.equalsIgnoreCase(str2) && (DbType.MYSQL.getDb().equalsIgnoreCase(this.f71g) || DbType.MARIADB.getDb().equalsIgnoreCase(this.f71g));
        if (QueryRuleEnum.EMPTY.equals(queryRuleEnum)) {
            sb.append(m548c).append(" IS NULL ");
            if (z) {
                sb.append(" OR ").append(m548c).append(" = '' ");
            }
        } else if (QueryRuleEnum.NOT_EMPTY.equals(queryRuleEnum)) {
            sb.append(m548c).append(" IS NOT NULL ");
            if (z) {
                sb.append(CgformUtil.f207e).append(m548c).append(" != '' ");
            }
        }
        this.f77m.append(" (").append((CharSequence) sb).append(") ");
    }

    /* renamed from: b */
    private void m556b(String str, String str2, Object obj) {
        m573a(str, str2, obj, (String) null);
    }

    /* renamed from: a */
    private void m573a(String str, String str2, Object obj, String str3) {
        String lowerCase = str2.toLowerCase();
        if (m541e(str2)) {
            if (CgformUtil.m314g(obj.toString())) {
                m559b(obj.toString());
            } else {
                m559b("''");
            }
        } else if ("datetime".equals(lowerCase)) {
            String trim = obj.toString().trim();
            if (trim.length() <= 10) {
                if ("end".equals(str3)) {
                    trim = trim + " 23:59:59";
                } else {
                    trim = trim + " 00:00:00";
                }
            }
            m558b(str, DateUtils.str2Date(trim, (SimpleDateFormat) DateUtils.datetimeFormat.get()));
        } else if ("date".equals(lowerCase)) {
            String trim2 = obj.toString().trim();
            if (trim2.length() > 10) {
                trim2 = trim2.substring(0, 10);
            }
            m549c(str, DateUtils.str2Date(trim2, (SimpleDateFormat) DateUtils.date_sdf.get()));
        } else {
            String trim3 = obj.toString().trim();
            if (trim3.startsWith(CgformUtil.f231C) && trim3.endsWith(CgformUtil.f231C) && this.f83s == 1) {
                m559b(trim3);
            } else {
                m544d(str, (Object) trim3);
            }
        }
    }

    /* renamed from: b */
    private void m557b(String str, String str2) {
        m570a(str, str2, this.f82r, (String) null);
    }

    /* renamed from: b */
    private void m555b(String str, String str2, String str3) {
        m569a(str, str2, this.f82r, str3, null);
    }

    /* renamed from: a */
    private void m570a(String str, String str2, String str3, String str4) {
        m569a(str, str2, str3, null, str4);
    }

    /* renamed from: c */
    private String m548c(String str, String str2) {
        String str3 = this.f69e + str;
        if (DbType.DM.getDb().equalsIgnoreCase(this.f71g) && ExtendJsonKey.f133f.equalsIgnoreCase(str2)) {
            str3 = "CONVERT(VARCHAR(5000)," + str3 + ")";
        }
        return str3;
    }

    /* renamed from: a */
    private void m569a(String str, String str2, String str3, String str4, String str5) {
        if (this.f84t) {
            this.f84t = false;
        } else {
            this.f77m.append(" ").append(str3).append(" ");
        }
        if (null != str5 && !str5.isEmpty()) {
            this.f77m.append(str5);
        }
        if (!str.isEmpty()) {
            this.f77m.append(m548c(str, str4)).append(str2);
            return;
        }
        this.f77m.append(" ").append(str2).append(" ");
    }

    /* renamed from: b */
    private void m559b(String str) {
        this.f77m.append(str);
    }

    /* renamed from: d */
    private String m543d(String str, String str2) {
        String m537g = m537g(str);
        if (f67a.equals(this.f80p)) {
            return ":" + m537g;
        }
        String m550c = m550c(m537g);
        if (str2 == null) {
            return String.format("#{%s}", m550c);
        }
        return String.format("#{%s, jdbcType=%s}", m550c, str2);
    }

    /* renamed from: c */
    private String m550c(String str) {
        return "param." + m545d(str);
    }

    /* renamed from: a */
    private void m576a(String str, Object obj) {
        this.f79o.put(m545d(m536h(str)), obj);
    }

    /* renamed from: d */
    private String m545d(String str) {
        if (this.f83s == 1) {
            return str;
        }
        return this.f70f + "_" + str;
    }

    /* renamed from: b */
    private void m558b(String str, Object obj) {
        if (obj != null) {
            m559b(m543d(str, "TIMESTAMP"));
            m576a(str, obj);
        }
    }

    /* renamed from: c */
    private void m549c(String str, Object obj) {
        if (obj != null) {
            m559b(m543d(str, "DATE"));
            m576a(str, obj);
        }
    }

    /* renamed from: d */
    private void m544d(String str, Object obj) {
        if (obj != null) {
            m559b(m543d(str, (String) null));
            m576a(str, obj);
        }
    }

    /* renamed from: e */
    private boolean m541e(String str) {
        return "Long".equals(str) || "Integer".equals(str) || "int".equals(str) || "double".equals(str) || "BigDecimal".equals(str) || DataBaseConst.f577h.equals(str);
    }

    /* renamed from: f */
    private boolean m539f(String str) {
        return !"ORACLE".equals(str);
    }

    /* renamed from: a */
    public static String m578a(String str, long j) {
        return str.replaceFirst("\\?", String.valueOf(j));
    }

    /* renamed from: a */
    public static String m577a(String str, long j, long j2) {
        return str.replaceFirst("\\?", String.valueOf(j)).replaceFirst("\\?", String.valueOf(j2));
    }

    /* renamed from: e */
    private void m540e(String str, Object obj) {
        String str2;
        if (obj != null) {
            String[] split = obj.toString().split(CgformUtil.f233E);
            String str3 = "";
            String str4 = this.f69e + str;
            for (int i = 0; i < split.length; i++) {
                String str5 = str4 + " like '%" + split[i] + ",%' or " + str4 + " like '%," + split[i] + "%' or " + str4 + " = '" + split[i] + CgformUtil.f231C;
                if (str3.length() == 0) {
                    str2 = str5;
                } else {
                    str2 = str3 + " or " + str5;
                }
                str3 = str2;
            }
            if (str3.length() > 0) {
                m557b("", "(" + str3 + ")");
            }
        }
    }

    /* renamed from: f */
    private void m538f(String str, Object obj) {
        String str2;
        if (obj != null) {
            String str3 = this.f69e + str;
            String str4 = "";
            String[] split = obj.toString().split(CgformUtil.f233E);
            for (int i = 0; i < split.length; i++) {
                String format = String.format("popup_%s_%s", str, Integer.valueOf(i));
                String m543d = m543d(format, "VARCHAR");
                m576a(format, (Object) ("%" + split[i] + "%"));
                String str5 = str3 + CgformUtil.f208f + m543d;
                if (str4.length() == 0) {
                    str2 = str5;
                } else {
                    str2 = str4 + " or " + str5;
                }
                str4 = str2;
            }
            if (str4.length() > 0) {
                m557b("", "(" + str4 + ")");
            }
        }
    }

    public String getSubTableStr() {
        return this.f89c;
    }

    /* renamed from: a */
    private void m561a(Map<String, Object> map) {
        MatchTypeEnum byValue = MatchTypeEnum.getByValue(map.get("superQueryMatchType"));
        if (byValue == null) {
            byValue = MatchTypeEnum.AND;
        }
        Object obj = map.get("superQueryParams");
        if (obj == null || StringUtils.isBlank(obj.toString())) {
            return;
        }
        try {
            JSONArray parseArray = JSONArray.parseArray(URLDecoder.decode(obj.toString(), "UTF-8"));
            IOnlCgformFieldService iOnlCgformFieldService = (IOnlCgformFieldService) SpringContextUtils.getBean(IOnlCgformFieldService.class);
            ArrayList arrayList = new ArrayList();
            arrayList.add("JEECG_SUPER_QUERY_MAIN_TABLE");
            if (this.f89c != null && !"".equals(this.f89c)) {
                for (String str : this.f89c.split(CgformUtil.f233E)) {
                    arrayList.add(str);
                }
            }
            HashMap hashMap = new HashMap(5);
            StringBuffer stringBuffer = new StringBuffer();
            int i = 0;
            while (i < arrayList.size()) {
                String str2 = (String) arrayList.get(i);
                ArrayList arrayList2 = new ArrayList();
                for (int i2 = 0; i2 < parseArray.size(); i2++) {
                    JSONObject jSONObject = parseArray.getJSONObject(i2);
                    String string = jSONObject.getString("field");
                    if (!oConvertUtils.isEmpty(string)) {
                        String[] split = string.split(CgformUtil.f233E);
                        OnlineFieldConfig onlineFieldConfig = new OnlineFieldConfig(jSONObject);
                        if ("JEECG_SUPER_QUERY_MAIN_TABLE".equals(str2) && split.length == 1) {
                            if (CgformUtil.m314g(onlineFieldConfig.getVal()) || !"bigdecimal".equalsIgnoreCase(onlineFieldConfig.getType())) {
                                arrayList2.add(onlineFieldConfig);
                            }
                        } else if (split.length == 2 && split[0].equals(str2)) {
                            arrayList2.add(onlineFieldConfig);
                            if (((JSONObject) hashMap.get(str2)) == null) {
                                List<OnlCgformField> queryFormFieldsByTableName = iOnlCgformFieldService.queryFormFieldsByTableName(str2);
                                JSONObject jSONObject2 = new JSONObject();
                                for (OnlCgformField onlCgformField : queryFormFieldsByTableName) {
                                    if (StringUtils.isNotBlank(onlCgformField.getMainTable())) {
                                        jSONObject2.put("subTableName", str2);
                                        jSONObject2.put("subField", onlCgformField.getDbFieldName());
                                        jSONObject2.put("mainTable", onlCgformField.getMainTable());
                                        jSONObject2.put("mainField", onlCgformField.getMainField());
                                    }
                                }
                                hashMap.put(str2, jSONObject2);
                            }
                        }
                    }
                }
                if (arrayList2.size() > 0) {
                    ConditionHandler conditionHandler = new ConditionHandler(i == 0 ? this.f69e : this.f70f + i + ".", true, byValue.getValue());
                    conditionHandler.setDuplicateParamNameRecord(getDuplicateParamNameRecord());
                    conditionHandler.setDuplicateSqlNameRecord(getDuplicateSqlNameRecord());
                    String m565a = conditionHandler.m565a((List<OnlineFieldConfig>) arrayList2);
                    Map<String, Object> sqlParams = conditionHandler.getSqlParams();
                    if (m565a != null && m565a.length() > 0) {
                        if (i == 0) {
                            stringBuffer.append(" ").append(m565a).append(" ");
                            this.f79o.putAll(sqlParams);
                        } else {
                            JSONObject jSONObject3 = (JSONObject) hashMap.get(str2);
                            String format = String.format(" %s in (select %s from %s %s where ", jSONObject3.getString("mainField"), jSONObject3.getString("subField"), jSONObject3.getString("subTableName"), this.f70f + i);
                            this.f79o.putAll(sqlParams);
                            stringBuffer.append(byValue.getValue()).append(format).append(m565a).append(") ");
                        }
                    }
                }
                i++;
            }
            String stringBuffer2 = stringBuffer.toString();
            if (stringBuffer2.length() > 0) {
                if (stringBuffer2.startsWith("AND ")) {
                    stringBuffer2 = stringBuffer2.substring(3);
                } else if (stringBuffer2.startsWith("OR ")) {
                    stringBuffer2 = stringBuffer2.substring(2);
                }
                m557b("", "(" + stringBuffer2 + ")");
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }

    /* renamed from: g */
    private String m537g(String str) {
        return m566a(str, this.f86v);
    }

    /* renamed from: h */
    private String m536h(String str) {
        return m566a(str, this.f87w);
    }

    /* renamed from: a */
    private String m566a(String str, Map<String, String> map) {
        String str2 = map.get(str);
        if (str2 == null) {
            str2 = str;
            map.put(str, str + "_1");
        } else {
            map.put(str, str + "_" + (Integer.parseInt(str2.substring(str2.lastIndexOf("_") + 1)) + 1));
        }
        return str2;
    }
}
